package com.zjeav.lingjiao.ui.personCenter;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.dalimao.corelibrary.swipeback.SwipeBackActivity;
import com.zjeav.lingjiao.R;

public class ModifyInfoActivity extends SwipeBackActivity {

    private Button btnok;
    private EditText name_txt;
    private String type;
    private int resultcode;
    private TextView tv_text;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.modify_info_layout);

        btnok = findViewById(R.id.btnok);
        name_txt = findViewById(R.id.name_txt);
        tv_text = findViewById(R.id.tv_text);

        type = getIntent().getExtras().getString("type","");
        if ("name".equals(type)){
            tv_text.setText("姓名");
            name_txt.setHint("请输入姓名");
            resultcode = 1;
        }else if ("school".equals(type)){
            tv_text.setText("学校");
            name_txt.setHint("请输入学校名称");
            resultcode = 2;
        }else if ("modifyphone".equals(type)){
            tv_text.setText("手机号");
            name_txt.setHint("请输入学校名称");
            String phone = getIntent().getExtras().getString("phone","");
            name_txt.setText(phone);
            resultcode = 5;
        }else if ("email".equals(type)){
            tv_text.setText("邮箱");
            name_txt.setHint("请输入邮箱");
            String phone = getIntent().getExtras().getString("email","");
            name_txt.setText(phone);
            resultcode = 6;
        }

        btnok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent();
                intent.putExtra("editname",name_txt.getText().toString());
                setResult(resultcode,intent);
                finish();
            }
        });

    }
}
